xenconsole: fix assumption about printed max domid length.
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 17 Jun 2009 06:23:06 +0000 (07:23 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 17 Jun 2009 06:23:06 +0000 (07:23 +0100)
Also snprintf includes the final '\0' in the char count.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
tools/console/client/main.c

index b66baf8ae6655e98e3b25b68b7dd28a054b04935..63e729acabba74a00de711877b4927a12fc254be 100644 (file)
@@ -306,10 +306,10 @@ int main(int argc, char **argv)
        dom_path = xs_get_domain_path(xs, domid);
        if (dom_path == NULL)
                err(errno, "xs_get_domain_path()");
-       path = malloc(strlen(dom_path) + strlen("/serial/0/tty") + 3);
+       path = malloc(strlen(dom_path) + strlen("/serial/0/tty") + 5);
        if (path == NULL)
                err(ENOMEM, "malloc");
-       snprintf(path, strlen(dom_path) + strlen("/serial/0/tty") + 2, "%s/serial/%d/tty", dom_path, num);
+       snprintf(path, strlen(dom_path) + strlen("/serial/0/tty") + 5, "%s/serial/%d/tty", dom_path, num);
 
        /* FIXME consoled currently does not assume domain-0 doesn't have a
           console which is good when we break domain-0 up.  To keep us